##########################################
## "Voters get what they want"          ##
##########################################
## Heinrich, Kobayashi, Long            ##
##########################################

##          
## Prep CCES data
## Script 10
## June 29, 2017


## Load CCES data
####################
cces <- read.dta("data/cces_common_cumulative_4.dta")
cces <- subset(cces, year == 2012)

cces$Gender <- ifelse(cces$gender == "Female", 0, 1)
cces$HiEdu <- ifelse(cces$educ %in% c("4-year", "Post-grad"), 1, 0)
cces$LifeGotWorse <- ifelse(cces$economy_retrospective %in% c("Gotten much worse", "Gotten worse"), 1, 0)
cces$LR <- 1
cces$LR[cces$pid7 == "Not very strong Democrat"] <- 2
cces$LR[cces$pid7 == "Lean Democrat"] <- 3
cces$LR[cces$pid7 == "Independent"] <- 4
cces$LR[cces$pid7 == "Lean Republican"] <- 5
cces$LR[cces$pid7 == "Not very strong Republican"] <- 6
cces$LR[cces$pid7 == "Strong Republican"] <- 7
cces$LR[is.na(cces$pid7) == TRUE] <- NA
cces$LR[cces$pid7 == "Not sure"] <- NA

cces$Age <- 2015 - cces$birthyr

cces <- cces[, c("weight", "Age", "Gender", "LifeGotWorse", "LR", "HiEdu")]
cces <- na.omit(cces)


## Save prepped CCES data
#########################
save(cces, file="output/data_preppedCCES.Rdata")




